/*    */ package com.Ticker.util;
/*    */ 
/*    */ import java.awt.Color;
/*    */ import java.awt.Dimension;
/*    */ import java.awt.FlowLayout;
/*    */ import java.awt.event.ActionEvent;
/*    */ import java.awt.event.ActionListener;
/*    */ import javax.swing.JButton;
/*    */ import javax.swing.JColorChooser;
/*    */ import javax.swing.JLabel;
/*    */ import javax.swing.JPanel;
/*    */ 
/*    */ public class ColorSelectorPanel extends JPanel
/*    */   implements ActionListener
/*    */ {
/*    */   private static final long serialVersionUID = -6728727989773058896L;
/*    */   private String displayLabel;
/* 22 */   private Color color = Color.white;
/*    */   private String id;
/*    */   private ColorSelectorListener listener;
/*    */   private JButton selectButton;
/*    */ 
/*    */   public ColorSelectorPanel(String displayLabel)
/*    */   {
/* 28 */     this(displayLabel, null, null, null);
/*    */   }
/*    */ 
/*    */   public ColorSelectorPanel(String displayLabel, Color color) {
/* 32 */     this(displayLabel, color, null, null);
/*    */   }
/*    */ 
/*    */   public ColorSelectorPanel(String displayLabel, Color color, String id) {
/* 36 */     this(displayLabel, color, id, null);
/*    */   }
/*    */ 
/*    */   public ColorSelectorPanel(String displayLabel, Color color, String id, ColorSelectorListener listener) {
/* 40 */     this.displayLabel = displayLabel;
/* 41 */     this.color = color;
/* 42 */     this.id = id;
/* 43 */     this.listener = listener;
/* 44 */     createGUI();
/*    */   }
/*    */ 
/*    */   private void createGUI() {
/* 48 */     this.selectButton = new JButton();
/* 49 */     this.selectButton.setPreferredSize(new Dimension(15, 15));
/* 50 */     this.selectButton.setActionCommand(this.displayLabel);
/* 51 */     this.selectButton.setBackground(this.color);
/* 52 */     this.selectButton.addActionListener(this);
/*    */ 
/* 54 */     JLabel selectLabel = new JLabel(this.displayLabel);
/*    */ 
/* 56 */     setLayout(new FlowLayout(0, 5, 1));
/* 57 */     add(this.selectButton);
/* 58 */     add(selectLabel);
/*    */   }
/*    */ 
/*    */   public void actionPerformed(ActionEvent e) {
/* 62 */     String command = e.getActionCommand();
/* 63 */     if (command.equals(this.displayLabel)) {
/* 64 */       Color newColor = JColorChooser.showDialog(this, "Choose a color", this.color);
/* 65 */       if (newColor != null) {
/* 66 */         this.selectButton.setBackground(newColor);
/* 67 */         this.listener.setColor(this.id, newColor);
/*    */       }
/*    */     }
/*    */   }
/*    */ 
/*    */   public void setColor(Color color) {
/* 73 */     this.color = color;
/* 74 */     this.selectButton.setBackground(color);
/*    */   }
/*    */ 
/*    */   public void setID(String id) {
/* 78 */     this.id = id;
/*    */   }
/*    */ 
/*    */   public void setListener(ColorSelectorListener listener) {
/* 82 */     this.listener = listener;
/*    */   }
/*    */ }

/* Location:           C:\Users\os\Downloads\TrimOnline.jar
 * Qualified Name:     Ticker.util.ColorSelectorPanel
 * JD-Core Version:    0.5.4
 */